package com.ruoyi.certificate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.certificate.domain.CertificateCount;
import com.ruoyi.certificate.service.ICertificateCountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合格证打印记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/certificate/certificate_count")
public class CertificateCountController extends BaseController
{
    @Autowired
    private ICertificateCountService certificateCountService;

    /**
     * 查询合格证打印记录列表
     */
    @PreAuthorize("@ss.hasPermi('certificate:certificate_count:list')")
    @GetMapping("/list")
    public TableDataInfo list(CertificateCount certificateCount)
    {
        startPage();
        List<CertificateCount> list = certificateCountService.selectCertificateCountList(certificateCount);
        return getDataTable(list);
    }

    /**
     * 导出合格证打印记录列表
     */
    @PreAuthorize("@ss.hasPermi('certificate:certificate_count:export')")
    @Log(title = "合格证打印记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CertificateCount certificateCount)
    {
        List<CertificateCount> list = certificateCountService.selectCertificateCountList(certificateCount);
        ExcelUtil<CertificateCount> util = new ExcelUtil<CertificateCount>(CertificateCount.class);
        util.exportExcel(response, list, "合格证打印记录数据");
    }

    /**
     * 获取合格证打印记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('certificate:certificate_count:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(certificateCountService.selectCertificateCountById(id));
    }

    /**
     * 新增合格证打印记录
     */
    @PreAuthorize("@ss.hasPermi('certificate:certificate_count:add')")
    @Log(title = "合格证打印记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CertificateCount certificateCount)
    {
        return toAjax(certificateCountService.insertCertificateCount(certificateCount));
    }

    /**
     * 修改合格证打印记录
     */
    @PreAuthorize("@ss.hasPermi('certificate:certificate_count:edit')")
    @Log(title = "合格证打印记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CertificateCount certificateCount)
    {
        return toAjax(certificateCountService.updateCertificateCount(certificateCount));
    }

    /**
     * 删除合格证打印记录
     */
    @PreAuthorize("@ss.hasPermi('certificate:certificate_count:remove')")
    @Log(title = "合格证打印记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(certificateCountService.deleteCertificateCountByIds(ids));
    }
}
